package com.bocloud.cmp.dao;

import java.util.List;
import java.util.Map;

import com.bocloud.cmp.entity.resource.Rack;
import com.bocloud.cmp.model.Scope;
import com.bocloud.common.model.Param;
import com.bocloud.common.model.SimpleBean;
import com.bocloud.database.core.intf.GenericDao;

/**
 * 机柜抽象DAO接口
 * 
 * @author wei wei
 * @version 1.0
 * @since 2016.02.27
 */
public interface RackDao extends GenericDao<Rack, Long> {

	/**
	 * 查询机柜详细
	 * 
	 * @param id
	 *            the id
	 * @return the rack
	 * @throws Exception
	 */
	public Rack query(Long id) throws Exception;

	/**
	 * 查询机柜列表
	 * 
	 * @param page
	 *            the page
	 * @param rows
	 *            the rows
	 * @param params
	 *            the params
	 * @param sorter
	 *            the sorter
	 * @return the result
	 * @throws Exception
	 */
	public List<Rack> list(int page, int rows, List<Param> params, Map<String, String> sorter) throws Exception;

	/**
	 * 查询机柜简易列表
	 * 
	 * @param params
	 *            the params
	 * @param sorter
	 *            the sorter
	 * @return the bean
	 * @throws Exception
	 */
	public List<SimpleBean> list(List<Param> params, Map<String, String> sorter) throws Exception;

	/**
	 * 设置空闲机柜(机房)
	 * 
	 * @param id
	 *            the id
	 * @param userId
	 *            the user id
	 * @return
	 * @throws Exception
	 */
	public boolean releaseRoom(Long id, Long userId) throws Exception;

	/**
	 * 设置归属机柜(机房)
	 * 
	 * @param id
	 *            the id
	 * @param roomId
	 *            the room id
	 * @param userId
	 *            the user id
	 * @return
	 * @throws Exception
	 */
	public boolean belongRoom(Long id, Long roomId, Long userId) throws Exception;

	/**
	 * 查询机柜列表(没有被分配机房和分区)
	 * 
	 * @return the rack list
	 * @throws Exception
	 */
	public List<Rack> listFree() throws Exception;

	/**
	 * 查询机柜列表(没有被分配分区和其他机房)
	 * 
	 * @return the rack list
	 * @throws Exception
	 */
	public List<Rack> listFree(Long roomId) throws Exception;

	/**
	 * 查询符合条件的数据数量
	 * 
	 * @param params
	 *            the params
	 * @return count
	 * @throws Exception
	 */
	public int count(List<Param> params) throws Exception;

	/**
	 * 删除机柜
	 * 
	 * @param id
	 *            the id
	 * @param userId
	 *            the user id
	 * @return
	 * @throws Exception
	 */
	public boolean remove(Long id, Long userId) throws Exception;

	/**
	 * 检查机柜是否存在
	 * 
	 * @param params
	 *            the list param
	 * @return
	 * @throws Exception
	 */
	public boolean exists(List<Param> params) throws Exception;

	/**
	 * 获取机房的行数列数范围
	 * 
	 * @param roomId
	 *            the room id
	 * @return the scope
	 * @throws Exception
	 */
	public Scope range(Long roomId) throws Exception;
}
